<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>


    <title>商品修改</title>

    <link rel="shortcut icon" href="favicon.ico"/>
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet"/>
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet"/>
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet"/>
    <link href="css/animate.css" rel="stylesheet"/>
    <link href="css/style.css?v=4.1.0" rel="stylesheet"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet"/>
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet"/>
    <link href="css/animate.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="css/plugins/simditor/simditor.css" />
    <link href="css/style.css?v=4.1.0" rel="stylesheet"/>

    <link rel="shortcut icon" href="favicon.ico"/>
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet"/>
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet"/>
    <link href="css/animate.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="css/plugins/webuploader/webuploader.css"/>
    <link rel="stylesheet" type="text/css" href="css/demo/webuploader-demo.css"/>
    <link href="css/style.css?v=4.1.0" rel="stylesheet"/>
</head>

<body class="gray-bg">
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h1>修改商品 <small></small></h1>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form method="post" action="wl_commodity_Update" class="form-horizontal" enctype="multipart/form-data">
                    <div class="form-group">
                        <!-- 商品id -->
                        <input th:value="${wl_commodity_ByIdList.getId()}" type="text" name="id" class="form-control" style="width: 300px;border-radius: 4%; display:none;"/><br/>

                        <label class="col-sm-2 control-label">商品名称：</label>
                        <input required th:value="${wl_commodity_ByIdList.getCommodityname()}" type="text" name="commodityname" class="form-control" style="width: 300px;border-radius: 4%;"/><br/>
                        <label class="col-sm-2 control-label">商品类型：</label>
                        <select class="form-control m-b" name="categoryid" style="width: 300px;">
                            <option th:each="wl:${wl_category_getAllCateName_List}" th:text="${wl.catename}" th:value="${wl.cateid}"></option>
                        </select><br/>
                        <label class="col-sm-2 control-label">原价：</label><input min="0" required type="number" title="请填写数字"  name="oprice" th:value="${wl_commodity_ByIdList.getOprice()}"  class="form-control" style="width: 300px;border-radius: 4%;"/><br/>
                        <label class="col-sm-2 control-label">现价：</label><input min="0" required type="number" title="请填写数字" name="cprice" th:value="${wl_commodity_ByIdList.getCprice()}"  class="form-control" style="width: 300px;border-radius: 4%;"/><br/>
                        <label class="col-sm-2 control-label">商品编号：</label><input required type="text" name="commoditycode" th:value="${wl_commodity_ByIdList.getCommoditycode()}" class="form-control" style="width: 300px;border-radius: 4%;"/><br/>
                        <label class="col-sm-2 control-label">渠道：</label>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='1'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" checked="checked"/> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" /> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" /> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" /> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='2'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" /> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" checked="checked"/> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" /> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" /> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='3'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" /> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" /> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" checked="checked"/> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" /> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='4'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" /> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" /> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" /> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" checked="checked"/> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='12'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" checked="checked"/> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" checked="checked"/> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" /> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" /> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='13'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" checked="checked"/> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" /> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" checked="checked"/> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" /> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='14'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" checked="checked"/> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" /> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" /> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" checked="checked"/> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='23'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" /> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" checked="checked"/> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" checked="checked"/> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" /> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='24'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" /> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" checked="checked"/> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" /> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" checked="checked"/> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='34'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" /> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" /> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" checked="checked"/> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" checked="checked"/> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='123'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" checked="checked"/> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" checked="checked"/> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" checked="checked"/> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" /> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='124'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" checked="checked"/> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" checked="checked"/> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" /> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" checked="checked"/> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='234'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" /> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" checked="checked"/> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" checked="checked"/> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" checked="checked"/> <i></i> Android</label>
                        </div>
                        <div class="checkbox i-checks" th:if="${wl_commodity_ByIdList.getChannel()=='1234'}">
                            <label>
                                <input type="checkbox" value="1"  name="channelcheck" checked="checked"/> <i></i> WeChat</label>
                            <label>
                                <input type="checkbox" value="2"  name="channelcheck" checked="checked"/> <i></i> PC</label>
                            <label>
                                <input type="checkbox" value="3"  name="channelcheck" checked="checked"/> <i></i> iOS</label>
                            <label>
                                <input type="checkbox" value="4"  name="channelcheck" checked="checked"/> <i></i> Android</label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">上架状态：</label>
                        <div class="radio i-checks" th:if="${wl_commodity_ByIdList.getStatus()==1}">
                            <label>
                                <input type="radio" value="1"  name="status"  checked="checked"/> <i></i>已上架</label>
                            <label>
                                <input type="radio"  value="0"  name="status" /> <i></i>未上架</label>
                        </div>
                        <div class="radio i-checks" th:if="${wl_commodity_ByIdList.getStatus()==0}">
                            <label>
                                <input type="radio" value="1"  name="status" /> <i></i>已上架</label>
                            <label>
                                <input type="radio"  value="0"  name="status" checked="checked"/> <i></i>未上架</label>
                        </div><br/>
                        <label class="col-sm-2 control-label">代理状态：</label>
                        <div class="radio i-checks" th:if="${wl_commodity_ByIdList.getIsproxy()==1}">
                            <label>
                                <input type="radio" value="1"  name="isproxy" checked="checked"/> <i></i>可代理</label>
                            <label>
                                <input type="radio"  value="0"  name="isproxy" /> <i></i>不可代理</label>
                        </div>
                        <div class="radio i-checks" th:if="${wl_commodity_ByIdList.getIsproxy()==0}">
                            <label>
                                <input type="radio" value="1"  name="isproxy" /> <i></i>可代理</label>
                            <label>
                                <input type="radio"  value="0"  name="isproxy" checked="checked"/> <i></i>不可代理</label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">积分：</label>
                        <input title="请填写数字" min="0" type="number" required name="integral" th:value="${wl_commodity_ByIdList.getIntegral()}" class="form-control" style="width: 300px;border-radius: 4%;"/>
                        <br/>
                        <div>
                            <h2>商品属性</h2>
                            <hr/>
                        </div>
                        <button style="width: 70px" class="btn btn-info " id="button_0" type="button"><span style="font-size: 20px">+</span></button>
                        <button class="btn btn-info " type="button">库存操作</button>
                        <br/>
                        <table id="table_s">
                            <tr id="1">
                                <td width="300px"><button style="width: 70px" class="btn btn-info " id="button_1" onclick="quchu('button_1')" type="button"><span style="font-size: 20px">-</span></button></td>
                                <td style="width: 50px">属性：</td><td style="width: 500px"><input type="text"  name="shux"  class="form-control" style="width: 300px;border-radius: 4%;"/></td>
                                <td style="width: 100px">属性值：</td><td><input type="text"  name="shuxz"  class="form-control" style="width: 300px;border-radius: 4%;"/></td>
                            </tr>
                        </table>
                    </div>
                    <div id="lunbimg">
                        <h2>已有轮播图</h2>
                        <div th:each="sub,subStat:${subimgs}">
                            <span id="img${subStat.index}"><img th:src="${sub}" width="75px"></span>&nbsp;&nbsp;
                            <span id="qc${subStat.index}" onclick="updLb(${subStat.index})"><i class="fa fa-close"></i></span>
                            <span id="wbks${subStat.index}"><input type="hidden" value="${sub}" id="wbk${subStat.index}" name="imagelb"></span>
                            &nbsp;&nbsp;&nbsp;
                        </div>
                    </div>
                    <div>
                        <h2>商品轮播图上传</h2>
                        <div class="wrapper wrapper-content animated fadeIn">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="ibox float-e-margins">
                                        <div class="ibox-content">
                                            <div class="page-container">
                                                <div id="uploader" class="wu-example">
                                                    <div class="queueList">
                                                        <div id="dndArea" class="placeholder">
                                                            <div id="filePicker"></div>
                                                            <p>或将照片拖到这里，单次最多可选300张</p>
                                                        </div>
                                                    </div>
                                                    <div class="statusBar" style="display:none;">
                                                        <div class="progress">
                                                            <span class="text">100%</span>
                                                            <span class="percentage"></span>
                                                        </div>
                                                        <div class="info"></div>
                                                        <div class="btns">
                                                            <div id="filePicker2"></div>
                                                            <div class="uploadBtn" onclick="uploadImage()">开始上传</div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                       </div>
                    <div class="wrapper wrapper-content">
                        <h2>商品详情</h2>
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-content">
                                        <textarea id="editor" placeholder="这里输入内容"  autofocus name="detail" >
                                            <span required th:text="${wl_commodity_ByIdList.getDetail()}"></span>
                                        </textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="upimage">
                    </div>
                    <button type="submit" class="btn btn-primary">保存信息</button>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<!-- simditor -->
<script type="text/javascript" src="js/plugins/simditor/module.js"></script>
<script type="text/javascript" src="js/plugins/simditor/uploader.js"></script>
<script type="text/javascript" src="js/plugins/simditor/hotkeys.js"></script>
<script type="text/javascript" src="js/plugins/simditor/simditor.js"></script>
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = 'js/plugins/webuploader';
</script>
<script src="js/plugins/webuploader/webuploader.min.js"></script>

<script src="js/demo/webuploader-demo.js"></script>

<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>
<script>
    function uploadImage() {
        var $lenth = $(".filelist li").length;
        for (var i=0;i<$lenth;i++) {
            var asd = $(".filelist li:eq("+i+")").children().children().attr("src");
            var asd1 = $(".filelist li:eq("+i+")").children('.title').text();
            asd = JSON.stringify(asd)
            $.ajax({
                type: 'POST',
                url: 'upImg',
                data: {
                    base64: asd,
                    imags:asd1
                },
                async: false,
                dataType: 'json',
                success: function (data) {
                    //alert(data.valueOf())
                    if (data.valueOf()) {
                        alert('上传成功');
                        $("#upimage").append("<input type='hidden' id='1w' name='image' value='"+asd1+"'/>");
                    } else {
                        alert('上传失败');
                    }
                },
                error: function (err) {
                    alert('网络故障');
                }
            });
        }
    }

    function quchu(id){
        var asd = $("#"+id+"").parent().parent().attr("id");
        $("#"+asd+"").html("");
    }
    $(function(){
        $("#button_0").click(function () {
            var lasttr = $('#table_s tr:last').attr('id')
            var ids = (parseInt(lasttr)+1);
            $("#table_s").append('<tr id="'+ids+'"> ' +
                '<td width="300px">'+
                '<button style="width:70px" class="btn btn-info" id="button_'+ids+'" onclick="quchu('+"'button_"+ids+"'"+')" type="button">'+
                '<span style="font-size: 20px">-</span>'+
                '</button>'+
                '</td>'+
                '<td style="width: 50px">属性：</td>'+
                '<td style="width: 500px">' +
                '<input type="text" name="shux"  class="form-control" style="width: 300px;border-radius: 4%;"/>'+
                '</td>'+
                '<td style="width: 100px">属性值：</td>'+
                '<td>' +
                '<input type="text" name="shuxz" class="form-control" style="width: 300px;border-radius: 4%;"/>' +
                '</td>'+
                '</tr>')
        })
    $(document).ready(function () {
        var editor = new Simditor({
            textarea: $('#editor'),
            defaultImage: 'img/a9.jpg'
        });
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        $('.summernote').summernote({
            lang: 'zh-CN'
        });

    });
    var edit = function () {
        $("#eg").addClass("no-padding");
        $('.click2edit').summernote({
            lang: 'zh-CN',
            focus: true
        });
    };
    var save = function () {
        $("#eg").removeClass("no-padding");
        var aHTML = $('.click2edit').code(); //save HTML If you need(aHTML: array).
        $('.click2edit').destroy();
    };
    });

    $(function() {
        $.ajax({
            type: "post",//请求方式  
            url: "wl_commodity_Ajax",//发送请求地址  
            dataType: "json",
            data: {//发送给数据库的数据  
            },
            //请求成功后的回调函数有两个参数  
            success: function (data, textStatus) {
                var objs = eval(data); //解析json对象 
//                var obj = objs.标准;

                var index = 1;
                //循环遍历出json数据的key value
                for(var item in objs){
                    //alert("key:"+item+"value:"+objs[item]);
                    var lasttr = $('#table_s tr:last').attr('id')
                    var ids = (parseInt(lasttr)+1);
                    if(index==1){
                        $("#1 [name=shux]").val(item);
                        $("#1 [name=shuxz]").val(objs[item]);
                        index++;
                    }else {
                        //json里的对象超出一个时  动态添加文本框 并显示
                        $("#table_s").append('<tr id="' + ids + '"> ' +
                            '<td width="300px">' +
                            '<button style="width:70px" class="btn btn-info" id="button_' + ids + '" onclick="quchu(' + "'button_" + ids + "'" + ')" type="button">' +
                            '<span style="font-size: 20px">-</span>' +
                            '</button>' +
                            '</td>' +
                            '<td style="width: 50px">属性：</td>' +
                            '<td style="width: 500px">' +
                            '<input type="text" name="shux"  class="form-control" style="width: 300px;border-radius: 4%;"/>' +
                            '</td>' +
                            '<td style="width: 100px">属性值：</td>' +
                            '<td>' +
                            '<input type="text" name="shuxz" class="form-control" style="width: 300px;border-radius: 4%;"/>' +
                            '</td>' +
                            '</tr>')
                        $("#"+ids+" [name=shux]").val(item);
                        $("#"+ids+" [name=shuxz]").val(objs[item]);
                    }
                }
            }
        });
    });
</script>

<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<!--统计代码，可删除-->





</body>

</html>
